//
//  AppDelegate.m
//  汽车大灯色温蓝牙
//
//  Created by dfwx on 2020/9/5.
//  Copyright © 2020 zhongdaodianzi. All rights reserved.
//

#import "AppDelegate.h"
#import "MainViewController.h"
#import "LearnView.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    NSArray  *languages = [NSLocale preferredLanguages];
    //判断当前系统语言
    NSString *language = [languages objectAtIndex:0];
    NSLog(@"%@",languages);
    if ([language hasPrefix:@"zh-Han"]) {
        //我这里的需求是，如果不是中文，则APP语言都显示成英文，
        //先把它存在NSUserDefaults中
        [[NSUserDefaults standardUserDefaults] setObject:@"zh-Hans" forKey:@"appLanguage"];
    }else if ([language hasPrefix:@"ja"]) {
        [[NSUserDefaults standardUserDefaults] setObject:@"ja" forKey:@"appLanguage"];
        
        
    } else{
        //en.lproj 是英文资源包的文件名字
        [[NSUserDefaults standardUserDefaults] setObject:@"en" forKey:@"appLanguage"];
    }
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    
    MainViewController *containerVC = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    YBBaseNavigationController *nav = [[YBBaseNavigationController alloc]initWithRootViewController:containerVC];
//    MainTabBarViewController *tabBarVC = [[MainTabBarViewController alloc]init];
    [self.window setRootViewController:nav];
    
    NSString *string = [[NSUserDefaults standardUserDefaults]objectForKey:isFirstLogin];
    if (string.length == 0) {
        LearnView *learnView = [[[NSBundle mainBundle]loadNibNamed:@"LearnView" owner:nil options:nil]lastObject];
        learnView.frame = [NSObject mainWindow].bounds;
        [[NSObject mainWindow] addSubview:learnView];
        [[NSUserDefaults standardUserDefaults]setObject:@"yes" forKey:isFirstLogin];
    }
    
    
        
    return YES;
    
}





@end
